﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Hotnet.Entity.News>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<%
	NewsCategory category = ViewData["Category"] as NewsCategory;
%>
<%=string.Format("新闻列表 - <{0}> - 新闻管理 - Hotent后台管理", category.Name) %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

	<%
		NewsCategory category = ViewData["Category"] as NewsCategory;
	%>
	<div class="b1 p3">
		<h2><%=category.Name%></h2>
	</div>

	<p class="m5 tar">
		<%= Html.ActionLink("新增新闻", "Create", "AdminNews", new { categoryId = category.CategoryID }, null)%>
	</p>
	<%Html.BeginForm("Index", "AdminNewsCategory", new { categoryid = ViewData["CategoryID"] }); %>
		<div style=" text-align:center; margin-top:10px;">
				<span>
					新闻标题:<%=Html.TextBox("NewsName", null, new { style="width:80px;" })%>
				</span>
				<span>
					来源网站:<%=Html.DropDownList("SourceFromID", Hotnet.Web.Controllers.Admin.AdminNewsCategoryController.NewsNetList)%>
				</span>
				
				
				<span>
					排序:<%=Html.DropDownList("OrderType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumOrder>().Reverse())%>
				</span>
				<span>
					状态:<%=Html.DropDownList("IsPublished", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumPublishState>().Reverse())%>
				</span>
				<input type="submit" value="搜索" />
		</div>
	<%Html.EndForm(); %>

	<table width="100%" class="ma list">
		<tr>
			<th>序号</th>
			<%--<th>
				新闻编号
			</th>--%>
			<th>
				新闻标题
			</th>
			<th>
				所属分类
			</th>
			<th>
				新闻来源
			</th>
			<th>
				新闻日期
			</th>
			<th>
				是否有封面
			</th>
			<th>操作</th>
		</tr>
	<% 
		int id = 0;
		foreach (var item in Model) { 
	%>
		<tr>
			<td>
				<%=++id %>
			</td>
<%--			<td>
				<%=item.NewsID%>
			</td>--%>
			<td>
				<%=item.Title %>
			</td>
			<td>
				<%=category.Name%>
			</td>
			<td>
				<%=item.SourceFrom.Name %>
			</td>
			<td>
				<%= Html.Encode(String.Format("{0:g}", item.NewsTime)) %>
			</td>
			<td>
				<%=string.IsNullOrEmpty(item.ImagePath)?"无":"有" %>
			</td>
			<td align="center">
				<a href="javascript:setPublished(<%=item.NewsID %>);" id="setP<%=item.NewsID %>" <%=(item.IsPublished==1?"style='display:none;'":"") %>>发布</a>
				<a href="javascript:unSetPublished(<%=item.NewsID %>);" id="unsetP<%=item.NewsID %>" <%=(item.IsPublished==1?"":"style='display:none;'") %> >取消发布</a>
				<a href="/adminNews/setNewsList/<%=item.NewsID %>">设置列表</a><br />
				<%= Html.ActionLink("编辑", "Edit", "AdminNews",new { id=item.NewsID, categoryId = category.CategoryID }, null) %> 
				<%= Html.ActionLink("预览", "View", "News", new { id = item.NewsID }, new { target = "_blank" })%>|
				<a href="javascript:confirmDelete('确定要删除该新闻?', '/AdminNews/Delete/?categoryId=<%=category.CategoryID %>', <%=item.NewsID %>)">删除</a>
			</td>
		</tr>
	<% } %>
	</table>
	
	<%Html.RenderPartial("PaginateHelper", ViewData["PaginateHelper"] as PaginateHelper); %>
	
	<p class="m5 tar">
		<%= Html.ActionLink("新增新闻", "Create", "AdminNews", new { categoryId = category.CategoryID }, null)%>
	</p>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
<script type="text/javascript">

		function setPublished(newsID) {

			$.ajax(
			{
				url: "/AdminNews/SetPublished/",
				data: "newsID=" + newsID,
				type: "post",
				success: function() {
				document.getElementById("setP" + newsID).style.cssText = "display:none";
				document.getElementById("unsetP" + newsID).style.cssText = "";
				}
			}
			);
		}
		function unSetPublished(newsID) {

			$.ajax(
			{
				url: "/AdminNews/UnSetPublished/",
				data: "newsID=" + newsID,
				type: "post",
				success: function() {
				document.getElementById("setP" + newsID).style.cssText = "";
				document.getElementById("unsetP" + newsID).style.cssText = "display:none";
				}
			}
			);
		}
		
		$(document).ready(
			function() {

				$("#DefineType option[value='-1']").html("全部");
			}
		);
	
</script>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>

